﻿using System.ComponentModel.DataAnnotations;
using CID.Domain;

namespace CID.Web.Models
{
    public abstract class BaseNamedViewModel<T> : BaseViewModel<T>, INamedViewModel
        where T:INamedEntity
    {
        [Required(ErrorMessage = "You must provide a name")]
        public string Name { get; set; }

        public BaseNamedViewModel() : base() { }

        public BaseNamedViewModel(T model) : base(model)
        {
            Name = model.Name;
        }

        public override void UpdateModel(T model)
        {
            base.UpdateModel(model);
            model.Name = Name;
        }
    }
}